/**
 * 事件回调函数类型
 * @template T - 事件参数类型元组
 */
export type EventCallback<T extends any[]> = (...args: T) => void | Promise<void>;

/**
 * 事件元数据接口，用于存储事件相关信息
 */
export interface EventMeta<T extends any[]> {
  callback: EventCallback<T>;
  context: any;
  sticky: boolean;
  once: boolean;
  timestamp: number; // 用于调试和事件排序
  listenerId: number;
}

/**
 * 粘性事件清理选项
 */
export type ClearStickyOption = {
  eventName?: string;
  force?: boolean;
};

/**
 * 事件监听选项
 */
export type EventListenerOptions = {
  sticky?: boolean;
  context?: any;
  once?: boolean;
};

/**
 * 事件触发结果
 */
export interface EmitResult {
  success: boolean;
  listenerCount: number;
  errorCount: number;
  errors: Array<{ error: Error; listener: EventCallback<any> }>;
}

/**
 * 事件总线统计信息
 */
export interface EventBusStats {
  eventCount: number;
  listenerCount: number;
  stickyEventCount: number;
  recentEvents: Array<{ name: string; timestamp: number; listenerCount: number }>;
}
